Class Services

Summary

Fully Qualified Name: CodeIgniter\Config\Services
Extends: BaseService

Description

Services Configuration file.

Services are simply other classes/libraries that the system uses to do its job. This is used by CodeIgniter to allow the core of the framework to be swapped out easily without affecting the usage within the rest of your application.

This is used in place of a Dependency Injection container primarily due to its simplicity, which allows a better long-term maintenance of the applications built on top of CodeIgniter. A bonus side-effect is that IDEs are able to determine what class you are calling whereas with DI Containers there usually isn't a way for them to do this.

Methods

Name Description Defined By
__callStatic() Provides the ability to perform case-insensitive calling of service names. BaseService
autoloader() The Autoloader class is the central class that handles our spl_autoload_register method, and helper methods. BaseService
cache() The cache class provides a simple way to store and retrieve complex data for later. Services
clirequest() The CLI Request class provides for ways to interact with a command line request. Services
curlrequest() The CURL Request class acts as a simple HTTP client for interacting with other servers, typically through APIs. Services
email() The Email class allows you to send email via mail, sendmail, SMTP. Services
encrypter() The Encryption class provides two-way encryption. Services
exceptions() The Exceptions class holds the methods that handle: Services
filters() Filters allow you to run tasks before and/or after a controller is executed. During before filters, the request can be modified, and actions taken based on the request, while after filters can act on or modify the response itself before it is sent to the client. Services
honeypot() The Honeypot provides a secret input on forms that bots should NOT fill in, providing an additional safeguard when accepting user input. Services
image() Acts as a factory for ImageHandler classes and returns an instance of the handler. Used like Services::image()->withFile($path)->rotate(90)->save(); Services
injectMock() Inject mock object for testing. BaseService
iterator() The Iterator class provides a simple way of looping over a function and timing the results and memory usage. Used when debugging and optimizing applications. Services
language() Responsible for loading the language string translations. Services
locator() The file locator provides utility methods for looking for non-classes within namespaced folders, as well as convenience methods for loading 'helpers', and 'libraries'. BaseService
logger() The Logger class is a PSR-3 compatible Logging class that supports multiple handlers that process the actual logging. Services
migrations() Return the appropriate Migration runner. Services
negotiator() The Negotiate class provides the content negotiation features for working the request to determine correct language, encoding, charset, and more. Services
pager() Return the appropriate pagination handler. Services
parser() The Parser is a simple template parser. Services
redirectResponse() The Redirect class provides nice way of working with redirects. Services
renderer() The Renderer class is the class that actually displays a file to the user. Services
request() The Request class models an HTTP request. Services
reset() Reset shared instances and mocks for testing. BaseService
response() The Response class models an HTTP response. Services
router() The Router class uses a RouteCollection's array of routes, and determines the correct Controller and Method to execute. Services
routes() The Routes service is a class that allows for easily building a collection of routes. Services
security() The Security class provides a few handy tools for keeping the site secure, most notably the CSRF protection tools. Services
session() Return the session manager. Services
throttler() The Throttler class provides a simple method for implementing rate limiting in your applications. Services
timer() The Timer class provides a simple way to Benchmark portions of your application. Services
toolbar() Return the debug toolbar. Services
typography() The Typography class provides a way to format text in semantically relevant ways. Services
uri() The URI class provides a way to model and manipulate URIs. Services
validation() The Validation class provides tools for validating input data. Services
viewcell() View cells are intended to let you insert HTML into view that has been generated by any callable in the system. Services

Method Details

__callStatic()

Provides the ability to perform case-insensitive calling of service names.

Parameter Name Type Description
$name string
$arguments array

Returns: mixed

autoloader()

The Autoloader class is the central class that handles our spl_autoload_register method, and helper methods.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Autoloader\Autoloader

cache()

The cache class provides a simple way to store and retrieve complex data for later.

Parameter Name Type Description
$config \Config\Cache
$getShared bool

Returns: \CodeIgniter\Cache\CacheInterface

clirequest()

The CLI Request class provides for ways to interact with a command line request.

Parameter Name Type Description
$config \Config\App
$getShared bool

Returns: \CodeIgniter\HTTP\CLIRequest

curlrequest()

The CURL Request class acts as a simple HTTP client for interacting with other servers, typically through APIs.

Parameter Name Type Description
$options array
$response \CodeIgniter\HTTP\ResponseInterface
$config \Config\App
$getShared bool

Returns: \CodeIgniter\HTTP\CURLRequest

email()

The Email class allows you to send email via mail, sendmail, SMTP.

Parameter Name Type Description
$config null
$getShared bool

Returns: \CodeIgniter\Email\Email|mixed

encrypter()

The Encryption class provides two-way encryption.

Parameter Name Type Description
$config mixed
$getShared bool

Returns: \EncrypterInterface Encryption handler

exceptions()

The Exceptions class holds the methods that handle:

Parameter Name Type Description
$config \Config\Exceptions
$request \CodeIgniter\HTTP\IncomingRequest
$response \CodeIgniter\HTTP\Response
$getShared bool

Returns: \CodeIgniter\Debug\Exceptions

filters()

Filters allow you to run tasks before and/or after a controller is executed. During before filters, the request can be modified, and actions taken based on the request, while after filters can act on or modify the response itself before it is sent to the client.

Parameter Name Type Description
$config mixed
$getShared bool

Returns: \CodeIgniter\Filters\Filters

honeypot()

The Honeypot provides a secret input on forms that bots should NOT fill in, providing an additional safeguard when accepting user input.

Parameter Name Type Description
$config \CodeIgniter\Config\BaseConfig|null
$getShared bool

Returns: \CodeIgniter\Honeypot\Honeypot|mixed

image()

Acts as a factory for ImageHandler classes and returns an instance of the handler. Used like Services::image()->withFile($path)->rotate(90)->save();

Parameter Name Type Description
$handler string
$config mixed
$getShared bool

Returns: \CodeIgniter\Images\Handlers\BaseHandler

injectMock()

Inject mock object for testing.

Parameter Name Type Description
$name string
$mock
$mock

Returns:

iterator()

The Iterator class provides a simple way of looping over a function and timing the results and memory usage. Used when debugging and optimizing applications.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Debug\Iterator

language()

Responsible for loading the language string translations.

Parameter Name Type Description
$locale string
$getShared bool

Returns: \CodeIgniter\Language\Language

locator()

The file locator provides utility methods for looking for non-classes within namespaced folders, as well as convenience methods for loading 'helpers', and 'libraries'.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Autoloader\FileLocator

logger()

The Logger class is a PSR-3 compatible Logging class that supports multiple handlers that process the actual logging.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Log\Logger

migrations()

Return the appropriate Migration runner.

Parameter Name Type Description
$config \CodeIgniter\Config\BaseConfig
$db \CodeIgniter\Database\ConnectionInterface
$getShared bool

Returns: \CodeIgniter\Database\MigrationRunner

negotiator()

The Negotiate class provides the content negotiation features for working the request to determine correct language, encoding, charset, and more.

Parameter Name Type Description
$request \CodeIgniter\HTTP\RequestInterface
$getShared bool

Returns: \CodeIgniter\HTTP\Negotiate

pager()

Return the appropriate pagination handler.

Parameter Name Type Description
$config mixed
$view \CodeIgniter\View\RendererInterface
$getShared bool

Returns: \CodeIgniter\Pager\Pager

parser()

The Parser is a simple template parser.

Parameter Name Type Description
$viewPath string
$config mixed
$getShared bool

Returns: \CodeIgniter\View\Parser

redirectResponse()

The Redirect class provides nice way of working with redirects.

Parameter Name Type Description
$config \Config\App
$getShared bool

Returns: \CodeIgniter\HTTP\Response

renderer()

The Renderer class is the class that actually displays a file to the user.

The default View class within CodeIgniter is intentionally simple, but this service could easily be replaced by a template engine if the user needed to.

Parameter Name Type Description
$viewPath string
$config mixed
$getShared bool

Returns: \CodeIgniter\View\View

request()

The Request class models an HTTP request.

Parameter Name Type Description
$config \Config\App
$getShared bool

Returns: \CodeIgniter\HTTP\IncomingRequest

reset()

Reset shared instances and mocks for testing.

Parameter Name Type Description
$init_autoloader bool Initializes

Returns:

response()

The Response class models an HTTP response.

Parameter Name Type Description
$config \Config\App
$getShared bool

Returns: \CodeIgniter\HTTP\Response

router()

The Router class uses a RouteCollection's array of routes, and determines the correct Controller and Method to execute.

Parameter Name Type Description
$routes \CodeIgniter\Router\RouteCollectionInterface
$request \CodeIgniter\HTTP\Request
$getShared bool

Returns: \CodeIgniter\Router\Router

routes()

The Routes service is a class that allows for easily building a collection of routes.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Router\RouteCollection

security()

The Security class provides a few handy tools for keeping the site secure, most notably the CSRF protection tools.

Parameter Name Type Description
$config \Config\App
$getShared bool

Returns: \CodeIgniter\Security\Security

session()

Return the session manager.

Parameter Name Type Description
$config \Config\App
$getShared bool

Returns: \CodeIgniter\Session\Session

throttler()

The Throttler class provides a simple method for implementing rate limiting in your applications.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Throttle\Throttler

timer()

The Timer class provides a simple way to Benchmark portions of your application.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Debug\Timer

toolbar()

Return the debug toolbar.

Parameter Name Type Description
$config \Config\Toolbar
$getShared bool

Returns: \CodeIgniter\Debug\Toolbar

typography()

The Typography class provides a way to format text in semantically relevant ways.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\Typography\Typography

uri()

The URI class provides a way to model and manipulate URIs.

Parameter Name Type Description
$uri string
$getShared bool

Returns: \CodeIgniter\HTTP\URI

validation()

The Validation class provides tools for validating input data.

Parameter Name Type Description
$config \Config\Validation
$getShared bool

Returns: \CodeIgniter\Validation\Validation

viewcell()

View cells are intended to let you insert HTML into view that has been generated by any callable in the system.

Parameter Name Type Description
$getShared bool

Returns: \CodeIgniter\View\Cell

Top